import 'package:flutter_admin/pages/common/cry/model/response_body_api.dart';
import 'package:flutter_admin/utils/kwargs.dart';
import 'package:flutter_admin/utils/odoo_http_util.dart';

class MrpWorkorderApi {
  static Future<ResponseBodyApi> page({data}) async {
    ResponseBodyApi responseBodyApi;
    try {
      List domainList = data['domainList'];
      Kwargs recordsKwargs = Kwargs(
        domain: domainList,
      );
      var records = await OdooHttpUtil.callKw(
        model: 'mrp.workorder',
        method: 'search_read',
        kwargs: recordsKwargs.toMap(),
      );
      List<Map<String, dynamic>> list = [];
      records.forEach((element) {
        Map<String, dynamic> map = element;
        list.add(map);
      });
      responseBodyApi = ResponseBodyApi(success: true, data: records);
    } catch (e) {
      responseBodyApi =
          ResponseBodyApi(success: false, message: '请求出错了：' + e.toString());
    }
    return responseBodyApi;
  }
}
